//设置
import React, { Component } from 'react'
import {
    View,
    Text,
    TouchableOpacity,
    ScrollView,
} from 'react-native';

import { installStyle as styles } from '../../../../styles';
import Icon from 'react-native-vector-icons/Ionicons';

const isFirst = true;
import stirageUtil from '../../../util/AsyncStorageUtil'
import { header, header2, header3 } from '../../../util/fetch'
import { NavigationActions } from 'react-navigation';
let Dimensions = require('Dimensions');
let width = Dimensions.get('window').width;

export default class Install_body extends Component {
    constructor(props) {            //构造器只执行一次
        super(props);

    };

    goOut() {
        stirageUtil.delete("accountToken").then(() => {
            stirageUtil.delete("userType").then(() => {
                header.accessToken = null
                header2.accessToken = null
                header3.accessToken = null
                resetAction = NavigationActions.reset({
                    index: 0,
                    actions: [
                        NavigationActions.navigate({ routeName: 'Login' })//要跳转到的页面名字
                    ]
                });
                this.props.navigation.dispatch(resetAction);
            })
        });
    }
    goEmail() {
        if (this.props.msg.emailmsg == 'ok') {
            this.props.navigation.navigate('Inschange_email');
        }
    }

    render() {
        return (
            <ScrollView style={styles.scroll}>

                <TouchableOpacity activeOpacity={1} style={styles.everyone}
                    onPress={() => { this.props.navigation.navigate('Password') }}>
                    <View style={styles.everyin}>
                        <Icon
                            name={'ios-brush'}
                            size={20}
                            color={'#aeaeae'} style={styles.insicon2} />

                        <Text style={styles.inscentext}>修改密码</Text>
                    </View>

                    <Icon
                        name={'ios-arrow-forward'}
                        size={20}
                        color={'#aeaeae'} style={styles.postopicon2} />
                </TouchableOpacity>

                <TouchableOpacity
                    activeOpacity={1} style={styles.everyone}
                    onPress={() => { this.goEmail.bind(this) }}>
                    <View style={styles.everyin}>
                        <Icon
                            name={'ios-mail'}
                            size={20}
                            color={'#aeaeae'} style={styles.insicon2} />

                        <Text style={styles.inscentext}>邮箱</Text>
                    </View>
                    {this.props.msg.emailmsg == 'err' ?
                        <View style={styles.everyin}>
                            <Text style={styles.inscentext}>{this.props.msg.email}</Text>
                        </View>
                        :
                        <Icon
                            name={'ios-arrow-forward'}
                            size={20}
                            color={'#aeaeae'} style={styles.postopicon2} />
                        // null
                    }
                    {/* <Icon
                        name={'ios-arrow-forward'}
                        size={20}
                        color={'#aeaeae'} style={styles.postopicon2} /> */}
                </TouchableOpacity>

                <TouchableOpacity activeOpacity={1} style={styles.everythree}
                    onPress={() => { this.props.navigation.navigate('Phone', { phone: this.props.msg.phonemsg }) }}>
                    <View style={styles.everyin}>
                        <Icon
                            name={'md-phone-portrait'}
                            size={20}
                            color={'#aeaeae'} style={styles.insicon2} />

                        <Text style={[styles.inscentext,{marginLeft:4}]}>手机号</Text>
                    </View>

                    <Icon
                        name={'ios-arrow-forward'}
                        size={20}
                        color={'#aeaeae'} style={styles.postopicon2} />
                </TouchableOpacity>

                <TouchableOpacity activeOpacity={1} style={styles.everyone}
                    onPress={() => { this.props.navigation.navigate('Suggestion') }}>
                    <View style={styles.everyin}>
                        <Icon
                            name={'md-help-circle'}
                            size={20}
                            color={'#aeaeae'} style={styles.insicon2} />

                        <Text style={styles.inscentext}>意见反馈</Text>
                    </View>

                    <Icon
                        name={'ios-arrow-forward'}
                        size={20}
                        color={'#aeaeae'} style={styles.postopicon2} />
                </TouchableOpacity>

                <TouchableOpacity activeOpacity={1} style={styles.everytwo} onPress={() => { }}>
                    <View style={styles.everyin}>
                        <Icon
                            name={'md-repeat'}
                            size={20}
                            color={'#aeaeae'} style={styles.insicon2} />

                        <Text style={styles.inscentext}>版本更新</Text>
                    </View>

                    <View style={styles.everyright}>
                        <Text style={styles.righttext}>已是最新版本</Text>
                        <Icon
                            name={'ios-arrow-forward'}
                            size={20}
                            color={'#aeaeae'} style={styles.postopicon2} />

                    </View>
                </TouchableOpacity>

                <TouchableOpacity activeOpacity={1} style={styles.everytwo}
                    onPress={() => { this.props.navigation.navigate('About_us') }}>
                    <View style={styles.everyin}>
                        <Icon
                            name={'ios-happy-outline'}
                            size={20}
                            color={'#aeaeae'} style={styles.insicon2} />

                        <Text style={styles.inscentext}>关于我们</Text>
                    </View>

                    <Icon
                        name={'ios-arrow-forward'}
                        size={20}
                        color={'#aeaeae'} style={styles.postopicon2} />
                </TouchableOpacity>

                <TouchableOpacity activeOpacity={1} style={styles.everyone} onPress={() => {
                    stirageUtil.get("accountToken").then((res) => {
                        //console.log(res)
                    })
                }}>
                    <View style={styles.everyin}>
                        <Icon
                            name={'md-build'}
                            size={20}
                            color={'#aeaeae'} style={styles.insicon2} />
                        <Text style={styles.inscentext}>清除缓存</Text>
                    </View>

                    <Icon
                        name={'ios-arrow-forward'}
                        size={20}
                        color={'#aeaeae'} style={styles.insiconr} />
                </TouchableOpacity>

                <TouchableOpacity activeOpacity={1} style={[styles.insbutton, {
                    width: width * 1, elevation: 3,
                    shadowColor: 'black'
                }]} onPress={() => { this.goOut() }}>
                    <Text style={styles.instestb}>退出登录</Text>
                </TouchableOpacity>

            </ScrollView>


        )
    }
}